package com.fer.tankr;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.EditText;
import android.widget.Toast;

import com.parse.ParseObject;

public class RequestActivity extends Activity implements OnClickListener{

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_request);
		findViewById(R.id.button1).setOnClickListener(this);
		
	}
	
	@Override
	public void onClick(View v) {
		EditText text = (EditText) findViewById(R.id.editText2);
		if (text.getText()!=null && text.getText().length()>5)
		{
			ParseObject req = new ParseObject("Request");
			req.put("request", text.getText().toString());
			try {
				req.saveInBackground();
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			Toast.makeText(this, "Your request has been received, thank you",  Toast.LENGTH_LONG).show();
			Intent intent = new Intent(this, MainActivity.class);
			startActivity(intent);
		}
	}

}
